define(function(require, exports, modules) {
	var $ = require('jquery');
	require("jqueryMore");
	var common2_localstorage = window.localStorage;
	var Common2 = {
		cityname: "",
		cityId: "",
		getPcParam: function(obj) {

			Common2.cityname = Common2.request("companyName") == undefined ? common2_localstorage.getItem("cityname") : Common2.request("companyName");
			
			//城市显示去除中间空格
			if(Common2.cityname != undefined && Common2.cityname != '') {
				Common2.cityname = Common2.cityname.replace(' ', '');
			}

			if(Common2.cityname) {

				obj.html(Common2.cityname);
				common2_localstorage.setItem("cityname", Common2.cityname);
			} else {
				Common2.InitCity(obj);
			}

		},
		getCityNameById: function(cityId) {
			return;
			if(cityId) {
				var htmlobj = $.ajax({
					url: $.M.baseUrl + "/sys/getProvinceById/" + cityId,
					async: false
				});
				data = eval('(' + htmlobj.responseText + ')');
				if(data.objValue.length != 0) {
					return data.objValue[0].name;
				} else {
					return "";
				}
			}

		},
		Init: function(obj) {
			var fromFlag = Common2.request("from");
			if(common2_localstorage.getItem("oldCompanyId") == "null" || common2_localstorage.getItem("oldCompanyId") == undefined) {
				common2_localstorage.setItem("oldCompanyId", Common2.request("oldCompanyId") == undefined ? "null" : Common2.request("oldCompanyId"));
			}

			if(!fromFlag || fromFlag.indexOf('null') > -1) {
				fromFlag = null;
				common2_localstorage.setItem("from", fromFlag);
			}
			if(!fromFlag) {

				fromFlag = common2_localstorage.getItem("from");
				if(!fromFlag || fromFlag.indexOf('null') > -1) {
					fromFlag = null;
				}
				if(!fromFlag) { // 如果没有标记，说明从微信来，需要去掉图片
					Common2.cityname = Common2.request("companyName");
					Common2.cityId = Common2.request("companyId") == undefined ? common2_localstorage.getItem("cityId") : Common2.request("companyId");
					if(Common2.cityId != undefined) {
						Common2.cityname = Common2.getCityNameById(Common2.cityId);
					}

					if(Common2.cityname == undefined || Common2.cityname == "" || Common2.cityId == undefined || Common2.cityId == "null") {

						Common2.getPcParam(obj);
					}
					obj.html(Common2.cityname);
					common2_localstorage.setItem("cityId", Common2.cityId);
					common2_localstorage.setItem("cityname", Common2.cityname);
				} else {
					Common2.getPcParam(obj);
					common2_localstorage.setItem("from", fromFlag);
				}
			} else {

				Common2.cityId = Common2.request("companyId") == undefined ? common2_localstorage.getItem("cityId") : Common2.request("companyId");
				common2_localstorage.setItem("cityId", Common2.cityId);

				Common2.getPcParam(obj);
				common2_localstorage.setItem("from", fromFlag);
			}
			return fromFlag;
		},
		InitCity: function(obj) {
			var htmlobj = $.ajax({
				url: $.M.baseUrl + "/rest/company/queryDefaultCompany",
				async: false
			});
			data = eval('(' + htmlobj.responseText + ')');
			obj.html(data.objValue.district);
			Common2.cityId = data.objValue.districtDomain;
			Common2.cityname = data.objValue.district;
			common2_localstorage.setItem("cityname", data.objValue.district);
			common2_localstorage.setItem("cityId", data.objValue.districtDomain);

		},
		request: function(strParame) {
			var args = new Object();
			var query = location.href;
			var newQuery = query.substring(query.indexOf('?') + 1);
			var pairs = newQuery.split("&"); // Break at ampersand
			for(var i = 0; i < pairs.length; i++) {
				var pos = pairs[i].indexOf('=');
				if(pos == -1)
					continue;
				var argname = pairs[i].substring(0, pos);
				var value = pairs[i].substring(pos + 1);
				value = decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(decodeURIComponent(value))))));
				args[argname] = value;
			}
			return args[strParame];
		}
	}
	return Common2;
});